package com.ruoyi.tsjData.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.tsjData.domain.plat.DataTshjZhdu;
import com.ruoyi.tsjData.service.IDataTshjZhduService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 提升机照度测试项Controller
 * 
 * @author ruoyi
 * @date 2024-02-28
 */
@RestController
@RequestMapping("/tsjData/zhdu")
public class DataTshjZhduController extends BaseController
{
    @Autowired
    private IDataTshjZhduService dataTshjZhduService;

    /**
     * 查询提升机照度测试项列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhdu:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataTshjZhdu dataTshjZhdu)
    {
        startPage();
        List<DataTshjZhdu> list = dataTshjZhduService.selectDataTshjZhduList(dataTshjZhdu);
        return getDataTable(list);
    }

    /**
     * 导出提升机照度测试项列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhdu:export')")
    @Log(title = "提升机照度测试项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataTshjZhdu dataTshjZhdu)
    {
        List<DataTshjZhdu> list = dataTshjZhduService.selectDataTshjZhduList(dataTshjZhdu);
        ExcelUtil<DataTshjZhdu> util = new ExcelUtil<DataTshjZhdu>(DataTshjZhdu.class);
        util.exportExcel(response, list, "提升机照度测试项数据");
    }

    /**
     * 获取提升机照度测试项详细信息
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhdu:query')")
    @GetMapping(value = "/{zhduId}")
    public AjaxResult getInfo(@PathVariable("zhduId") Long zhduId)
    {
        return success(dataTshjZhduService.selectDataTshjZhduByZhduId(zhduId));
    }

    /**
     * 新增提升机照度测试项
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhdu:add')")
    @Log(title = "提升机照度测试项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataTshjZhdu dataTshjZhdu)
    {
        return toAjax(dataTshjZhduService.insertDataTshjZhdu(dataTshjZhdu));
    }

    /**
     * 修改提升机照度测试项
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhdu:edit')")
    @Log(title = "提升机照度测试项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataTshjZhdu dataTshjZhdu)
    {
        return toAjax(dataTshjZhduService.updateDataTshjZhdu(dataTshjZhdu));
    }

    /**
     * 根据id和任务id变更数据状态
     */
    @ApiOperation(value="根据id和任务id变更数据状态")
    @PreAuthorize("@ss.hasPermi('tsjData:zhdu:editByIdAndDataId')")
    @PostMapping("/editByIdAndDataId/{dataTaskId}/{zhduId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long"),
            @ApiImplicitParam(paramType="query", name = "zhduId", value = "环境id", required = true, dataType = "Long"),
    })
    public AjaxResult editByIdAndDataId(@PathVariable("dataTaskId")Long dataTaskId, @PathVariable("zhduId") Long zhduId) {
        return toAjax(dataTshjZhduService.updateDataTshjZhduByZhduId(dataTaskId, zhduId));
    }

    /**
     * 删除提升机照度测试项
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhdu:remove')")
    @Log(title = "提升机照度测试项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zhduIds}")
    public AjaxResult remove(@PathVariable Long[] zhduIds)
    {
        return toAjax(dataTshjZhduService.deleteDataTshjZhduByZhduIds(zhduIds));
    }
}
